package com.wenhui.schoolyardinfo.square.ui;

import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.qmuiteam.qmui.widget.QMUITopBar;
import com.wenhui.schoolyardinfo.R;
import com.wenhui.schoolyardinfo.base.BaseActivity;
import com.wenhui.schoolyardinfo.callback.RcvOnItemViewClickListener;
import com.wenhui.schoolyardinfo.firstpage.ui.SearchActivity;
import com.wenhui.schoolyardinfo.square.adapter.MineJoinPublicGoodAdapter;
import com.wenhui.schoolyardinfo.square.bean.PublicGoodBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * author    : mahognyin
 * e-mail    : 1976222027@qq.com
 * date      : 2019/7/16 15:34
 * introduce : 我参加的公益
 */
public class MineJoinPublicGoodActivity extends BaseActivity implements RcvOnItemViewClickListener {
    private static final String TAG = "MineJoinPublicGoodActivity";
    @BindView(R.id.imv_back)
    ImageView imvBack;
    @BindView(R.id.layout_back)
    RelativeLayout layoutBack;
    @BindView(R.id.imv_search)
    ImageView imvSearch;
    @BindView(R.id.layout_search)
    RelativeLayout layoutSearch;
    @BindView(R.id.topbar)
    QMUITopBar topbar;
    @BindView(R.id.mine_recycler_view)
    RecyclerView mineRecyclerView;
    @BindView(R.id.view_bottom)
    View viewBottom;
    private List<PublicGoodBean> publicGoodBeanList;
    private MineJoinPublicGoodAdapter publicGoodAdapter;
    private LinearLayoutManager layoutManager;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mine_join_public_good);
        ButterKnife.bind(this);
        initData();
        initViews();
    }

    @Override
    protected void initData() {
        publicGoodBeanList = new ArrayList<>();
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1frv032vod8j30k80q6gsz.jpg",
                "救助站公益活动0", "发起人：隆美尔",
                7210000101010L, 10000010101010L));
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "救助站公益活动1", "发起人：隆美尔",
                7210000101010L, 10000010101010L));
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "救助站公益活动2", "发起人：隆美尔",
                9210000101010L, 10000010101010L));
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1frv032vod8j30k80q6gsz.jpg",
                "救助站公益活动3", "发起人：隆美尔",
                9210000101010L, 10000010101010L));
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "救助站公益活动4", "发起人：隆美尔",
                9210000101010L, 10000010101010L));
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1frv032vod8j30k80q6gsz.jpg",
                "救助站公益活动5", "发起人：隆美尔",
                9210000101010L, 10000010101010L));
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "救助站公益活动6", "发起人：隆美尔",
                7210000101010L, 10000010101010L));
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1frv032vod8j30k80q6gsz.jpg",
                "救助站公益活动7", "发起人：隆美尔",
                9210000101010L, 10000010101010L));
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "救助站公益活动8", "发起人：隆美尔",
                9210000101010L, 10000010101010L));
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1frv032vod8j30k80q6gsz.jpg",
                "救助站公益活动9", "发起人：隆美尔",
                9210000101010L, 10000010101010L));
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1fsfq1k9cb5j30sg0y7q61.jpg",
                "救助站公益活动10", "发起人：隆美尔",
                9210000101010L, 10000010101010L));
        publicGoodBeanList.add(new PublicGoodBean("http://ww1.sinaimg.cn/large/0065oQSqly1frv032vod8j30k80q6gsz.jpg",
                "救助站公益活动11", "发起人：隆美尔",
                7210000101010L, 10000010101010L));

    }

    @Override
    protected void initViews() {
        setTopBar(topbar);
        initAdapter();
    }

    private void initAdapter() {
        layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(OrientationHelper.VERTICAL);
        mineRecyclerView.setLayoutManager(layoutManager);
        mineRecyclerView.setItemAnimator(new DefaultItemAnimator());

        publicGoodAdapter = new MineJoinPublicGoodAdapter(this,publicGoodBeanList);
        mineRecyclerView.setAdapter(publicGoodAdapter);
        publicGoodAdapter.setRcvOnItemViewClickListener(this);
//        publicGoodAdapter.clearData();
//        publicGoodAdapter.addAllData(publicGoodBeanList);
    }
    @Override
    public void onItemClickListener(int position, View view) {
        switch (view.getId()) {
            case R.id.layout_public_good:
                showToast("layout_public_good");
                break;
            default:
                break;
        }
    }

    @OnClick({R.id.layout_back, R.id.layout_search})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.layout_back:
                finish();
                break;
            case R.id.layout_search:
                startActivity(SearchActivity.class);
                break;
        }
    }
}
